import java.util.*;

public class Practice2 {
    //https://www.nowcoder.com/practice/635ff765d4af45b5bf8e3756ed415792?tpId=134&tqId=33860&ru=/exam/oj
    //一道排序题, 主要考察了set.toArray()的用法, 简单题
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Set<Integer> set = new HashSet<>();
        int n = sc.nextInt();
        int m = sc.nextInt();
        for(int i = 0;i < n + m;i++){
            set.add(sc.nextInt());
        }
        int len = set.size();
        Integer[] arr = new Integer[len];
        set.toArray(arr);
        Arrays.sort(arr);
        for(int i = 0;i < len;i++){
            System.out.print(arr[i] + " ");
        }

    }
}